import java.io.IOException;
import java.io.Serializable;
import java.util.AbstractCollection;
import java.util.ArrayList;
import java.util.logging.*;



/**
 * This is the schedule class.
 */
public class Schedule implements Serializable{
	private AbstractCollection<Appointment> appointments;

	private static Logger scheduleLog = Logger.getLogger(Schedule.class.getName());

	static{
		ConsoleHandler console = new ConsoleHandler();
		console.setLevel(Level.ALL);
		console.setFormatter(new ThunderDragonHtmlFormatter());
		scheduleLog.addHandler(console);
		scheduleLog.setLevel(Level.ALL);
		
		try {
			FileHandler fh = new FileHandler("ScheduleLog.txt");
			fh.setFormatter(new ThunderDragonHtmlFormatter());
			scheduleLog.addHandler(fh);
		} catch (SecurityException e) {
			// TODO Auto-generated catch block
			scheduleLog.severe("Failure: Security exception thrown" +
					" when trying to create a new handler" +
					" in Schedule.java.");
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			scheduleLog.severe("Failure: I/O exception thrown" +
					" when trying to create a new handler " +
					"in Schedule.java.");
			e.printStackTrace();
		}
		
	}

	/**
	 * Constructor for Schedule.
	 * 
	 */	
	public Schedule() {
		scheduleLog.entering(this.getClass().getName(), "Schedule Constructor");
		appointments = new ArrayList<Appointment>();
		scheduleLog.exiting(this.getClass().getName(), "Schedule Constructor");
	}
	
	/**
	 * Method addAppointment. This method adds an appointment to the schedule
	 * 
	 */
	public void addAppointment(Appointment app){
		appointments.add(app);
		scheduleLog.finest("Called addAppointment() in class Schedule.");
	}
	
	/**
	 * This method removes an appointment from the schedule list.
	 */
	public void removeAppointment(Appointment app){
		appointments.remove(app);
		scheduleLog.finest("Called removeAppointment() in class Schedule.");
	}
	
	/**
	 * Method findByTime. Allows a user to find an available time slot for an appointment.
	 * @return double
	 */
	public double findByTime(){
		double time = 0;
		scheduleLog.finest("Called findByTime() in class Schedule.");
		return time;
		
	}
	
	/**
	 * Method findByDoctor. Allows a user to find an available appointment 
	 * time by when a specific doctor is available.
	 * @param doctor String
	 * @return String
	 */
	public String findByDoctor(String doctor){
		scheduleLog.finest("Called findByDoctor() in class Schedule.");
		return doctor = "";
	}

	@Override
	public String toString() {
		return "Schedule [appointments=" + appointments + "]";
	}
	
	
}
